/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年9月17日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package obsver.code;

import java.util.ArrayList;
import java.util.List;

/**
 * @Type Subject
 * @Desc
 * @author 52489
 * @date 2019年9月17日
 * @Version V1.0
 */
public class Subject {
    protected List<Observer> observers = new ArrayList<>();

    public void registerObserver(Observer observer) {
        observers.add(observer);
    }

    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    public void notifyAllObservers() {
        for (Observer observer : observers) {
            observer.update(this);
        }
    }

}
